// src/stores/useTagsStore.ts
import { defineStore } from 'pinia';
import {ref} from "vue";
export const useTagsStore = defineStore('tags', () => {
    const tagsMenu = ref<MenuType[]>([])

    type MenuType = {
        path:string
        name:string
        title: string
        icon: string
    }

    function setMenu(data: MenuType) {
        if(!tagsMenu.value.find(item => item.path === data.path)){
            tagsMenu.value.push(data)
        }
    }

    function removeMenu(data: MenuType) {

        const index = tagsMenu.value.findIndex(item =>  item.path === data.path);
        if (index > -1) {
            tagsMenu.value.splice(index, 1);
        }

    }

    return { tagsMenu, setMenu,removeMenu };
});